package com.kgc.scd.consumer;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.kgc.scd.bean.HotKey;
import com.kgc.scd.bean.SearchHistory;
import com.kgc.scd.contant.HotKeyConstant;
import com.kgc.scd.contant.SearchHistoryConstant;
import com.kgc.scd.mapper.HotKeyMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created On : 2022/6/14.
 * <p>
 * Author     : hi
 * <p>
 * Description: HotKeyConsumer
 */
@Slf4j
@RestController
public class HotKeyConsumer {
    @Autowired(required = false)
    private HotKeyMapper hotKeyMapper;

    /**
     * 从指定队列中，消费消息，进行业务处理 添加
     */
    @JmsListener(destination = HotKeyConstant.HOT_KEY_ADD_P2P)
    public void queueP2P(HotKey hotKey){
        HotKey hotKey1 = new HotKey();
        hotKey1.setHotkeyKey(hotKey.getHotkeyKey());
        hotKey1.setHotkeyScore(hotKey.getHotkeyScore());

        UpdateWrapper<HotKey> wrapper = new UpdateWrapper<>();
        wrapper.eq("hotkey_value",hotKey.getHotkeyValue());
        hotKeyMapper.update(hotKey1,wrapper);


    }

}
